# Contributor: ScrumpyJack <scrumpyjack@st.ilet.to>
# Maintainer: ScrumpyJack <scrumpyjack@st.ilet.to>
pkgname=w3m
_pkgver=0.5.3+git20200502
pkgver=${_pkgver/+git/.}
pkgrel=0
pkgdesc='Text-based Web browser, as well as pager'
url='https://github.com/tats/w3m'
license='MIT UCD'
arch='all'
makedepends="imlib2-dev openssl-dev gc-dev ncurses-dev linux-headers"
subpackages="$pkgname-doc"
source="$pkgname-$pkgver.tar.gz::https://github.com/tats/w3m/archive/v$_pkgver.tar.gz
	https.patch"
builddir="$srcdir/$pkgname-${_pkgver/+/-}"

# secfixes:
#   0.5.3.20180125-r0:
#     - CVE-2018-6196
#     - CVE-2018-6197
#     - CVE-2018-6198

build() {
	PERL=/usr/bin/perl ./configure \
		--prefix=/usr \
		--libexecdir=/usr/lib \
		--enable-image=fb \
		--with-ssl \
		--disable-nntp \
		--disable-dict \
		--disable-help-cgi \
		--with-imagelib=imlib2 \
		--with-termlib=ncurses \
		--disable-w3mmailer \
		--disable-mouse
	make -j1
}

check() {
	./w3m -version
}

package() {
	make DESTDIR="$pkgdir" install

	install -d "$pkgdir"/usr/share/doc/"$pkgname"
	install -d "$pkgdir"/usr/share/licenses/"$pkgname"
	local i; for i in doc/*; do
		install -m644 "$i" "$pkgdir"/usr/share/doc/"$pkgname"
	done
	ln -s /usr/share/doc/"$pkgname"/README \
		"$pkgdir"/usr/share/licenses/"$pkgname"
}

sha512sums="b43dfa37a5b057d4413373eb3e363765766f469696a85647994e8d98e98b108a682a1dbe3fdc87b96ec905ac27ccf1842cf7381d9137c2ce891010f93aef6047  w3m-0.5.3.20200502.tar.gz
3844b3a079524ad403da7fe03461210a433ff1cd562862c4df55c3be250ccba0c34eb61bcc8df1973d70e2ef034edaf1804bb2fa682b01723322f108f523932a  https.patch"
